package com.lagou.decimal;

import org.apache.hadoop.io.WritableComparable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

public class DecimalBean implements WritableComparable<DecimalBean> {

    private Long decimal;

    public DecimalBean(){

    }

    public DecimalBean(Long decimal){
        this.decimal = decimal;
    }

    public Long getDecimal() {
        return decimal;
    }

    public void setDecimal(Long decimal) {
        this.decimal = decimal;
    }

    @Override
    public void write(DataOutput out) throws IOException {
        out.writeLong(decimal);
    }

    @Override
    public void readFields(DataInput in) throws IOException {
        decimal = in.readLong();
    }

    @Override
    public int compareTo(DecimalBean o) {
        if (decimal > o.getDecimal()) {
            return 1;
        } else if (decimal < o.getDecimal()) {
            return -1;
        }
        return 0;
    }

    @Override
    public String toString(){
        return String.valueOf(decimal);
    }
}
